package day02;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServer implements Runnable{




    @Override
    public void run() {
        PrintWriter pw = null;

        ServerSocket socket = null;

        try {
            socket = new ServerSocket(9900);
            Socket sk = socket.accept();
            InetAddress iad = InetAddress.getLocalHost();
            InputStream is = sk.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));

            String str;

            while ((str = br.readLine()) != null){
                System.out.println(str);
            }
            String s = null;
            OutputStream os = sk.getOutputStream();
            os.write(s.getBytes());

            os.close();
            br.close();
            sk.close();
            socket.close();

        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
